package com.datastructure.test.issametree;

public class IsSameTree {

    public static void main(String[] args) {

    }

    public boolean isSameTree (TreeNode root1, TreeNode root2) {
        // write code here
        if(root1==null&&root2==null){
            return true;
        }
        if(root1!=null&&root2==null){
            return false;
        }
        if(root1 == null){
            return false;
        }
        return root1.val== root2.val&&isSameTree(root1.left,root2.left)&&isSameTree(root1.right,root2.right);
    }
}
class TreeNode {
   int val = 0;
   TreeNode left = null;
   TreeNode right = null;
   public TreeNode(int val) {
     this.val = val;
   }
}
